package tests;

import java.util.LinkedList;

import bookworm.BooksAndRatingOfOneAuthor;
import bookworm.SearchBestAuthorsBasedOnTag;

public class SearchBestAuthorsBasedOnTagTest 
{
	public static void main(String args[])
	{
		PrintTextInJFrame logWindow = new PrintTextInJFrame("log window for graph creation and visitor result");
		SearchBestAuthorsBasedOnTag searchBestAuthors =
				new SearchBestAuthorsBasedOnTag("storytime");
		LinkedList<BooksAndRatingOfOneAuthor> bestBooksOfTagBasedOnAuthors =
									searchBestAuthors.getBestAuthorsBooksAndRatingsBasedOnTag();
		logWindow.write("////we found " + String.valueOf(bestBooksOfTagBasedOnAuthors.size()) + " authors that write books from this tag");
		for(int i = 0; i < bestBooksOfTagBasedOnAuthors.size(); i++)
		{
			BooksAndRatingOfOneAuthor oneBooksAndRating = 
											bestBooksOfTagBasedOnAuthors.get(i);
			logWindow.write("//////////////////////////////////");
			logWindow.write("author=" + oneBooksAndRating.getAuthor());
			logWindow.write("has rating=" + oneBooksAndRating.getAverageRatingOfAuthorBasedOnTag());
			int howManyBooksFromAuthorAndTag = 
					oneBooksAndRating.getBooksFromAuthorRelatedToTag().size();
			logWindow.write("based on " + howManyBooksFromAuthorAndTag + " books");
			logWindow.write("based on tag storytime");
			logWindow.write("//////////////////////////////////");
		}	
	}

}
